package RobotPlayer
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	public class Hpgauge extends Sprite
	{
		public var HpNum:int = 0;
		public var CurrentHp:int = 0;
		private var shape:Shape;    
		private var shape1:Shape;
		private var shape2:Shape;
		private var w:int ;
		public function Hpgauge(_default:int,_w:int = 50)
		{
			HpNum = _default;
			w = _w;
			shape = new Shape();
			shape1 = new Shape();
			shape2 = new Shape();
			addChild(shape);
			addChild(shape1);
			addChild(shape2);
			shape.graphics.beginFill(0xcc9900);
			shape.graphics.drawRect(0, 0, w, 5);
			shape1.graphics.beginFill(0xff0000);
			shape1.graphics.drawRect(1, 1, w-2, 3);
			shape2.graphics.beginFill(0x00ff00);
			shape2.graphics.drawRect(1, 1, w - 2, 3);
			this.addEventListener(Event.ENTER_FRAME, function(e:Event):void
			{
				Update();
			});
		}
		
		public function SetHp(_hp:int):void
		{
			CurrentHp = _hp;
		}
		
		private function Update():void
		{
			shape2.width = int((CurrentHp / HpNum) * w);
		}
		
		
	}
}